home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 409 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.3 KB  |  61 lines

  1. Newsgroups: comp.lang.c
  2. Path: gail.ripco.com!mambuhl
  3. From: mambuhl@ripco.com (Martin Ambuhl)
  4. Subject: Re: prefix vs. postfix   
  5. X-Nntp-Posting-Host: golden.ripco.com
  6. Message-ID: <DKovAI.G26@rci.ripco.com>
  7. Sender: usenet@rci.ripco.com (Net News Admin)
  8. Organization: Ripco Internet BBS Chicago
  9. Date: Fri, 5 Jan 1996 03:35:05 GMT
  10. X-Ident-Sender: mambuhl
  11.  
  12. scicom@globalcom.net (stephen j beaver) in
  13. <4cf35v$7il@head.globalcom.net> wrote:
  14.  
  15. >I thought that:
  16.  
  17. >for(i=0;i<10;i++)
  18. >   {
  19. >   loopbody(i):
  20. >   }
  21.  
  22. >Increments i after the loop so that the first value passed to loopbody() is zer
  23. >, whereas:
  24.  
  25. >for(i=0;i<10;++i)
  26. >   {
  27. >  loopbody();
  28. >   }
  29.  
  30. >increments i before the loop body so that the first value passedtp loopbody() i
  31. > 1 in this case.
  32.  
  33. >No?
  34.  
  35. NO! from ISO 6.6.5.3:
  36.  
  37.     "Escept for the behavior of a continue statement in the loop body,
  38.     the statement
  39.  
  40.     for (expression-1;expression-2;expression-3) statement
  41.  
  42.     and the sequence of statements
  43.  
  44.     expression-1;
  45.     while(expression-2) {
  46.         statement
  47.         expression-3;
  48.  
  49.     }
  50.  
  51.     are equivalent."
  52.  
  53.  
  54. Notice that expression-3 does not move around depending on what it is.
  55. (Why would you think it did?)
  56.  
  57.                                                                          
  58. --
  59. * Martin Ambuhl       net: mambuhl@ripco.com
  60. * Chicago, IL (USA)    
  61.